Operation method

ABSTRACT

Aspects of data modification for neural networks are described herein. The aspects may include a connection value generator configured to receive one or more groups of input data and one or more weight values and generate one or more connection values based on the one or more weight values. The aspects may further include a pruning module configured to modify the one or more groups of input data and the one or more weight values based on the connection values. Further still, the aspects may include a computing unit configured to update the one or more weight values and/or calculate one or more input gradients.

BACKGROUND

Artificial Neural Networks (ANNs), or Neural Networks (NNs) for short,are algorithmic mathematical models imitating the behaviorcharacteristics of animal neural networks and performing the distributedconcurrent information processing. Depending on complexity of a system,such networks adjust interconnection among a great number of internalnodes, thereby achieving the purpose of information processing. Thealgorithm used by NNs may be vector multiplication (also referred as“multiplication”) and convolution, which widely adopts sign functionsand various approximations thereof.

As neural networks in animal brains, NNs consist of multipleinterconnected nodes. As shown in FIG. 3, each block represents a nodeand each arrow represents a connection between two nodes.

The calculation formula of a neuron can be briefly described asy=f(Σ_(i=0) ^(n) w_(i)*x_(i)), wherein x represents input data receivedat all input nodes connected to the output nodes, w representscorresponding weight values between the input nodes and the outputnodes, and f(x) is a nonlinear function, usually known as an activationfunction including those commonly used functions such as

$\frac{1}{1 + e^{- x}}\mspace{14mu} {and}\mspace{14mu} {\frac{e^{x} - e^{- x}}{e^{x} + e^{- x}}.}$

NNs are widely applied to a variety of applications, such as computervision, voice recognition and natural language processing. In recentyears, the scale of NNs has been growing. For example, in 1998, Lecun'sneural network for handwriting characters recognition includes less than1M weight values; while in 2012, Krizhevsky for participating ImageNetcompetition includes 60M weight values.

NNs are applications that require large amounts of calculation and greatbandwidth for memory access. The more weight values, the more amounts ofcalculation and memory access are required. In order to decrease theaccount of calculation and the number of weight values thereby reducingmemory access, a sparsely connected neural network may be implemented.

Even as the amount of calculation and the amount of memory access of NNsdramatically increase, a general-purpose processor is conventionallyadopted to calculate a sparse artificial neural network. With regard tothe general-purpose processor, the input neurons, output neurons andweight values are respectively stored in three arrays, meanwhile thereis an index array for storing the connection relation between eachoutput neuron and input neuron connected by weight values. At the timeof calculating, a major operation is a multiplication of input data anda weight value. Each calculation needs to search a weight valuecorresponding to the input data through the index array. Since thegeneral-purpose processor is weak in both calculation and memory access,demands of NNs may not be satisfied. Nevertheless, when multiplegeneral-purpose processors work concurrently, inter-processorcommunication becomes a performance bottleneck again. In some otherrespects, when calculating a neural network after pruning, eachmultiplication operation needs to re-search positions corresponding tothe weight values in the index array, which increases additionalcalculation amounts and memory access overhead. Thus, NNs calculation istime-consuming and power consuming. General-purpose processors need todecode an operation of a multiple-layer artificial neural network into along sequence of operations and memory access instructions, andfront-end decoding brings about a larger overhead.

Another known method to support the operations and training algorithmsof a sparsely connected artificial neural network is to use a graphicsprocessing unit (GPU). In such method a general-purpose register fileand a general-purpose stream processing unit are used to execute auniversal Single-instruction-multiple-data (SIMD) instruction to supportthe aforementioned algorithm. Since a GPU is a device specially designedfor executing graph and image operations as well as scientificcalculation, it fails to provide specific support for sparse artificialneural network operations. As such, GPUs also need a great amount offront-end decoding to execute sparse artificial neural networkoperations, thus leading to additional overheads. In addition, since GPUonly contains relatively small on-chip caching, then model data (e.g.,weight values) of a multiple-layer artificial neural network has to berepeatedly retrieved from outside the chip. Thus, off-chip bandwidthbecomes a main performance bottleneck while producing huge powerconsumption.

SUMMARY

The following presents a simplified summary of one or more aspects inorder to provide a basic understanding of such aspects. This summary isnot an extensive overview of all contemplated aspects and is intended toneither identify key or critical elements of all aspects nor delineatethe scope of any or all aspects. Its sole purpose is to present someconcepts of one or more aspects in a simplified form as a prelude to themore detailed description that is presented later.

One example aspect of the present disclosure provides an example neuralnetwork acceleration processor. The example neural network accelerationprocessor may include a connection value generator configured to receiveone or more groups of input data and one or more weight values andgenerate one or more connection values based on the one or more weightvalues. The example neural network acceleration processor may furtherinclude a pruning module configured to modify the one or more weightvalues based on the connection values. Further still, the example neuralnetwork acceleration processor may include a computing unit configuredto update the one or more weight values and/or calculate one or moreinput gradients.

Another example aspect of the present disclosure provides an examplemethod for modifying data for neural networks. The example method mayinclude receiving, by a connection value generator, one or more groupsof input data and one or more weight values; generating, by theconnection value generator, one or more connection values based on theone or more weight values; and modifying, by a pruning module, the oneor more weight values based on the connection values.

To the accomplishment of the foregoing and related ends, the one or moreaspects comprise the features hereinafter fully described andparticularly pointed out in the claims. The following description andthe annexed drawings set forth in detail certain illustrative featuresof the one or more aspects. These features are indicative, however, ofbut a few of the various ways in which the principles of various aspectsmay be employed, and this description is intended to include all suchaspects and their equivalents.

BRIEF DESCRIPTION OF THE DRAWINGS

The disclosed aspects will hereinafter be described in conjunction withthe appended drawings, provided to illustrate and not to limit thedisclosed aspects, wherein like designations denote like elements, andin which:

FIG. 1 is a block diagram illustrating an example computing process atan MNN acceleration processor for neural networks;

FIG. 2 is a block diagram illustrating an example computer system inwhich data modification for neural networks may be implemented;

FIG. 3 is a diagram illustrating a comparison between a regular MNN anda sparse MNN in which data modification for neural networks may beimplemented;

FIG. 4A and FIG. 4B are diagrams illustrating one or more connectionvalues in a sparse MNN in which data modification for neural networksmay be implemented;

FIG. 5 is a diagram illustrating a convolution process with which datamodification for neural networks may be implemented;

FIG. 6 is a diagram illustrating a convolution process with modifiedweight values with which data modification for neural networks may beimplemented;

FIG. 7 is a block diagram illustrating an example MNN accelerationprocessor in which data modification for neural networks may beimplemented;

FIG. 8 is a block diagram illustrating another example MNN accelerationprocessor in which data modification for neural networks may beimplemented;

FIG. 9 is a block diagram illustrating another example MNN accelerationprocessor in which data modification for neural networks may beimplemented;

FIG. 10 is a block diagram illustrating another example MNN accelerationprocessor in which data modification for neural networks may beimplemented;

FIG. 11 is a block diagram illustrating an example data modifier in anexample MNN acceleration processor in which data modification for neuralnetworks may be implemented; and

FIG. 12 is a flow chart of aspects of an example method for modifyingdata for neural networks.

DETAILED DESCRIPTION

Various aspects are now described with reference to the drawings. In thefollowing description, for purpose of explanation, numerous specificdetails are set forth in order to provide a thorough understanding ofone or more aspects. It may be evident, however, that such aspect(s) maybe practiced without these specific details.

In the present disclosure, the term “comprising” and “including” as wellas their derivatives mean to contain rather than limit; the term “or,”which is also inclusive, means and/or.

In this specification, the following various embodiments used toillustrate principles of the present disclosure are only forillustrative purpose, and thus should not be understood as limiting thescope of the present disclosure by any means. The following descriptiontaken in conjunction with the accompanying drawings is to facilitate athorough understanding of the illustrative embodiments of the presentdisclosure defined by the claims and its equivalent. There are specificdetails in the following description to facilitate understanding.However, these details are only for illustrative purpose. Therefore,persons skilled in the art should understand that various alternationand modification may be made to the embodiments illustrated in thisdescription without going beyond the scope and spirit of the presentdisclosure. In addition, for clear and concise purpose, some knownfunctionality and structure are not described. Besides, identicalreference numbers refer to identical function and operation throughoutthe accompanying drawings.

A typical conceptual model of a multi-layer neural network (MNN) mayinclude multiple layers of neurons. Each neuron is aninformation-processing unit that is fundamental to the operation of aneural network. In more detail, a typical model of a neuron may includethree basic elements, e.g., a set of synapses, an adder, and anactivation function. In a form of a mathematical formula, the outputsignals of a neuron may be represented as y_(k)=φ(Σ_(j=1) ^(m)w_(kj)x_(j)+b_(k)), in which y_(k) represents the output signals of theneuron, φ( ) represents the activation function, w_(kj) represents oneor more weight values, x_(j) represents the input signals of the neuron,and b_(k) represents a bias value. In other words, a simplified model ofa neuron may include one or more input nodes for receiving the inputsignals or data and an output node for transmitting the output signalsor data to an input node of another neuron at the next level. Thus, alayer of neurons may at least include a layer of multiple input nodesand another layer of output nodes.

FIG. 1 is a block diagram illustrating an example computing process 100at an MNN acceleration processor for neural networks. As depicted, theexample computing process 100 may be performed by a layer of input nodes102, a layer of output nodes 104, a layer of input nodes 106, and alayer of output nodes 108. A triangular-shaped operator (A as shown inFIG. 1) may indicate a matrix multiplication or a convolution operation.It is notable that the layers of input nodes and output nodes may not bethe first layer and the last layer of the entire neural network in theprocess. Rather, the layers of input and output nodes may refer to thenodes included in any two consecutive layers of neurons of a neuralnetwork. As described below in greater detail, the computing processfrom the layers of input nodes 102 to the layer of output nodes 108 maybe referred to as a forward propagation process; the computing processfrom the layer of output nodes 108 to the layer of input nodes 102 maybe referred to as a backward propagation process.

The forward propagation process may start from one or more input nodesthat receive input data 102A. The received input data 102A may bemultiplied or convolved by one or more weight values 102C. The resultsof the multiplication or convolution may be transmitted to one or moreoutput nodes at the layer of output nodes 104 as output data 104A. Theoutput data 104A, with or without further operations, may be transmittedto one or more input nodes at the next layer (e.g., the layer of inputnodes 106) as input data 106A. Similarly, the input data 106A may bemultiplied or convolved by one or more weight values 106C. The resultsof the multiplication or convolution may be similarly transmitted to oneor more output nodes at the layer of output nodes 108 as output data108A.

The backward propagation process may start from one or more output nodesat the last layer of nodes of the forward propagation process (e.g., thelayer of output nodes 108). For example, output gradients 108B generatedat the layer of output nodes 108 may be multiplied or convolved by theinput data 106A to generate weight gradients 106D at the layer of inputnodes 106. The output gradients 108B may be further multiplied orconvolved by the weight values 106C to generated input data gradients.The input data gradients 106B, with or without other operations betweenlayers, may be transmitted to one or more nodes at the layer of outputnodes 104 as output gradients 104B. The output gradients 104B may thenbe multiplied or convolved by the input data 102A to generate weightgradients 102D. Additionally, the output gradients 104B may bemultiplied by the weight values 102C to generate input data gradients102B.

FIG. 2 is a block diagram illustrating an example computer system 200 inwhich data modification for neural networks may be implemented. Theexample computer system 200 may include at least an I/O interface 202, acentral processing unit (CPU) 204, a multi-layer neural networkacceleration processor 206, and a memory 208. The I/O interface 202 maybe configured to exchange data or information with peripheral devices,e.g., input devices, storage devices, etc. Data received from the I/Ointerface 202 may be further processed at the CPU 204. Data that requireprocessing at an MNN may be transmitted to the MNN accelerationprocessor 206. For example, the forward propagation process and thebackward propagation process described above in accordance with FIG. 1may be performed at the MNN acceleration processor 206. Other data forthe forward propagation process and the backward propagation process,e.g., weight values 102C and 106C, may be retrieved from the memory 208and stored on the MNN acceleration processor 206 during the processes.However, as discussed above, the index array that indicates thecorrespondence between the input data and the weight values isconventionally stored on the memory 208. At each multiplication orconvolution that involves the weight values, retrieving the index arrayfrom the memory 208 may cause significant system delays or bandwidthconsumption. The MNN acceleration processor 206 may be described infurther detail below.

FIG. 3 is a diagram illustrating a comparison between a regular MNN 300Aand a sparse MNN 300B in which data modification for neural networks maybe implemented. As depicted, the regular MNN 300A may include a layer ofinput nodes 302 and a layer of output nodes 304. Each block shown in theregular MNN 300A indicates an input node or an output node. The arrowsbetween the input nodes (e.g., i₁ i₂, i₃ . . . i_(N)) and the outputnodes (e.g., o₁, o₂, o₃ . . . o_(N)) indicate those non-zero weightvalues for calculating the output data. For example, w₁₁ may be theweight value for calculating the output data at output node o₁ based onthe input data received at input node i₁. However, in some applicationsof neural networks, more than one of the weight values may be zero, inwhich case input data received at more than one input nodes are notconsidered for calculating some output data. In these cases, the arrowsbetween corresponding input nodes and output nodes will be deleted andthe MNN may be referred to as a sparse MNN, e.g., sparse MNN 300B. Asshown in the sparse MNN 300B, no arrow is between i₂ and O₁, i₁ and o₂,and i₄ and o₂, which indicates that the weight values, w₂₁, w₁₂, and w₄₂are zero.

As depicted in FIGS. 4A and 4B, one or more groups of input data may bereceived at the input nodes i₁, i₂, i₃, and i₄. In other words, inputdata may be received and stored in a form of input array that includeselements identified by array indexes i₁, i₂, i₃, and i₄. Similarly, oneor more groups of output data may be generated at output nodes o₁ ando₂. That is, the output data may be stored and transmitted in a form ofoutput array that include elements identified by array indexes o₁ ando₂. As an example of a sparse MNN, some input nodes are not connected tothe output nodes.

Connection data including one or more connection values may be generatedbased on the weight values corresponding to an output node and an inputnode.

That is, if a weight value corresponding to the output node and inputnode is zero, or the absolute value of the weight value is less than orequal to a first threshold value, the connection value for thecorresponding output node and input node may be generated as zero.Otherwise, if an absolute value of a weight value is greater than orequal to a second threshold value, a connection value for thecorresponding output node and input node may be set to one.

For example, the weight values for calculating output data at outputnode of may include w₁₁, w₂₁, w₃₁, and w₄₁, which respective correspondsto the input data received at input nodes i₁, i₂, i₃, and i₄. The weightvalues (w₁₁, w₂₁, w₃₁, and w₄₁) may be 0.5, 0, 0.6, and 0.8; the firstthreshold value may be predetermined to be 0.3; and the second thresholdvalue may be predetermined to be 0.4. Thus, absolute values of theweight values w₁₁, w₃₁, and w₄₁ are greater than the second thresholdvalue but the absolute value of the weight value w₂₁ is less than thefirst threshold value. As such, the connection values for i₁ and o₁, i₃and o₁, i₄ and o₁ may be generated as 1 and the connection value for i₂and o₁ may be generated as zero. Similarly, the connection values for i₁and o₂ and i₄ and o₂ may be set to zero and the connection values for i₂and o₂ and i₃ and o₂ may be set to one. Thus, the connection values foro₁ may be determined and stored to be 1011 and the connection values foro₂ may be determined to be 0110. The connection values in combinationmay be generated as 10110110.

In some other examples, the connection values may be generated withrespect to each input node. For example, with respect to the input nodei₁, the respective weight values w11 and w12 may be 1 and 0. Thus, theconnection values with respect to the input node i₁ may be set to as 10.For input nodes i₂, i₃, and i₄, the respective connection values may be01, 11, and 10. Thus, the connection values in combination may begenerated as 10011110.

In other examples (e.g., illustrated in FIG. 4B), connection values maybe generated based on a distance between the input nodes. A connectionvalue may be determined by the distances between different input nodesthat correspond to those weight values, of which the absolute values aregreater than or equal to the second threshold value (may be referred toas “connected nodes” interchangeably). With respect to the above exampleweight values, w₁₁, w₃₁, and w₄₁, of which the absolute values aregreater than the second threshold value, the connection value for inputnode i₁ may be set to a value equal to the distance between the previousconnected input node and the current connected input node. Thus, sincethe distance between input node i₁ and the previous connected node (alsoi₁ here) is zero, the connection value for i₁ may be set to zero. Withrespect to input node i₃, since the distance between input node i₃ andthe first input node (i₁) is 2, the connection value for i₃ may be setto 2. Thus, the connection values may be generated as 021. It is notablethat the illustration and the term “distance” are provided for purposeof brevity. Since the input data and the output data may be stored in aform of data array, the term “distance” may refer to the differencebetween array indexes. In some examples, the connection values may bestored in a form of a linked list or a multi-dimensional dynamic array.

Thus, as the connection values sufficiently represent the connectionsbetween the input nodes and the output nodes, the MNN accelerationprocessor 206 is not required to retrieve the index array from thememory 208 during the forward propagation process and the backwardpropagation process described in FIG. 1.

FIG. 5 is a diagram illustrating a convolution process with which datamodification for neural networks may be implemented. In this example, anexample convolution process between one or more groups of input data ina form of an input matrix

$\quad\begin{matrix}1 & 0 & 1 \\0 & 1 & 1 \\0 & 0 & 1\end{matrix}$

and weight values in a form of a weight matrix

$\quad\begin{matrix}1 & 1 \\1 & 0\end{matrix}$

is described. As shown, each element of the output matrix is calculatedby convolving a portion of the input matrix with the weigh matrix. Forexample, the output data at the output node o₁ may be calculated byconvolving the top left portion of the input matrix

$( {{i.e.},\begin{matrix}1 & 0 \\0 & 1\end{matrix}} )$

by the weight matrix. The result of the convolution process may bestored in an output matrix (e.g.,

$\quad\begin{matrix}1 & 2 \\1 & 2\end{matrix}$

as shown).

FIG. 6 is a diagram illustrating a convolution process with sparseweight matrix with which data modification for neural networks may beimplemented. As depicted, the top part of FIG. 6 shows a convolutionprocess between an input matrix and a weight matrix. The lower part ofFIG. 6 shows a convolution process between the input matrix and a sparseweight matrix. In the sparse weight matrix, weight values w₂ and w₃ aredeleted. Thus, rather than four times of convolution operations, it onlyrequires two convolution operations to generate the output matrix.Specifically, the connection values w₁₁, w₂₁, w₃₁, and w₄₁ may be set to(1, 0, 0, 1) or (0, 2) for the calculation of output data at outputnodes o₁ and o₄.

FIG. 7 is a block diagram illustrating an example MNN accelerationprocessor in which data modification for neural networks may beimplemented. As depicted, MNN acceleration processor 206 may at leastinclude a data modifier 702 configured to receive one or more groups ofinput data and a predetermined weight value array that includes one ormore weight values. As described above, the one or more groups of inputdata may be stored in a form of data array (“input array” hereinafter);that is, each group of the input data may be stored as an element of theinput array (“input element” hereinafter). Each input element may beidentified by an array index (“input array index” hereinafter; e.g., i₂,i₃, and i₄). Each of the weight values (e.g., w₁₁, w₂₁, w₃₁, and w₄₁)may be designated for calculating a group of output data at an outputnode (e.g., o₁) based on a respective group of input data (e.g., a groupof input data received at the input node i₁). The calculated output datamay be similarly stored in a form of data array (“output array”hereinafter); that is, each group of the output data may be stored as anelement of the output array (“output element” hereinafter). Each outputelement may be identified by an array index (“output array index”hereinafter; e.g., o₁ and o₂).

The data modifier 702 may be configured to generate connection data thatinclude one or more connection values based on the weight values. Eachof the connection values may correspond to an input array index (e.g.,i₂) and an output array index (e.g., o₁).

For example, as illustrated in FIG. 4A, the data modifier 702 may beconfigured to generate the connection values based on the weight valuesw₁₁, w₂₁, w₃₁, and w₄₁. Since the absolute value of the example weightvalue w₂₁ is less than the first threshold value and the absolute valuesof other weight values w₁₁, w₃₁, and w₄₁ are greater than the secondthreshold value, the data modifier 702 may be configured to generate theconnection values for output node o₁ as 1011. Similarly, the connectionvalues for o₂ may be generated as 0110 when the weight values w₁₂ andw₄₂ are less than or equal to the first threshold value.

In the example illustrated in FIG. 4B, the data modifier 702 may besimilarly configured to generate the connection values based on theweight values. For example, the data modifier 702 may be configured notto generate a connection value that corresponds to a weight value, ofwhich an absolute value is less than or equal to a first thresholdvalue.

Further, the data modifier 702 may be configured to modify the inputdata and the weight values based on the generated connection values. Forexample, with respect to the output node o₁, based on the connectionvalues of 1011, the data modifier 702 may be configured to delete theinput data corresponding to the connection values of zero, e.g., i₂, andto delete the weight value corresponding to the connection values ofzero, e.g., w₂₁. With respect to the output node o₂, based on theconnection values of 0110, the data modifier 702 may be configured todelete the input data corresponding to the connection values of zero,e.g., i₁ and i₄, and to delete the weight values corresponding to theconnection values of zero, e.g., w₁₂ and w₄₂. Thus, input data i₁, i₃,i₄, i₂, i₃ and the weight values w₁₁, w₃₁, w₄₁, w₂₂, w₃₂ may be outputby the data modifier 702.

The modified input data and/or the modified weight values in the form ofconnection pairs may be transmitted to and temporarily stored in an datacache 712 and/or a weight cache 714. The data cache 712 and weight cache714 may refer to one or more high-speed storage devices incorporatedwithin the MNN acceleration processor 206 and configured to store theinput data and the weight values respectively. The modified input dataand/or the modified weight values may be further transmitted to acomputing unit 710 for further processing.

MNN acceleration processor 206 may further include an instruction cache706 and a controller unit 708. The instruction cache 706 may refer oneor more storage devices configured to store instructions received fromthe CPU 204. The controller unit 708 may be configured to read theinstructions from the instruction cache 706 and decode the instructions.

Upon receiving the decoded instructions from the controller unit 708,the modified input data from the data cache 712, and the modified weightvalues from the weight cache 714, the computing unit 710 may beconfigured to calculate one or more groups of output data based on themodified weight values and the modified input data. In some respects,the calculation of the output data may include the forward propagationprocess and the backward propagation process described in accordancewith FIG. 1.

The computing unit 710 may further include one or more multipliersconfigured to multiply the modified input data by the modified weightvalues to generate one or more weighted input data, one or more addersconfigured to add the one or more weighted input data to generate atotal weighted value and add a bias value to the total weighted value togenerate a biased value, and an activation processor configured toperform an activation function on the biased value to generate a groupof output data.

The generated output data may be temporarily stored in an output datacache 716 and may be further transmitted to the memory 208 via the DMAmodule 704.

In an example backward propagation process illustrated in FIG. 1, thecomputing unit 710 may be configured to update the one or more weightvalues and/or calculate one or more input gradients based on themodified weight values and the modified input data.

For example, the computing unit 710 may be configured to update the oneor more weight values based on the connection values and one or moreoutput gradients, e.g., output gradients 104B. The output gradients 104Bmay be temporarily stored in the data cache 712. As shown in FIG. 1, theoutput gradients 104B may refer to the input gradients 106B that aretransmitted from another layer, with or without other operations.

In more detail, the computing unit 710 may be configured to multiply themodified input data with the output gradients 104B to generate one ormore weight differences. Further to the example illustrated in FIG. 4A,the computing unit 710 may be configured to retrieve the outputgradients OG₁ and OG₂ respectively for the output nodes o₁ and o₂ fromthe data cache 712. The input data modified with respect to the outputnode of may be i₃, and i₄; the input data modified with respect to theoutput node o₂ may be i₂ and i₃. The computing unit 710 may beconfigured to multiply the modified input data i₁, i₃, i₄, i₂, i₃respectively with the output gradients OG₁ and OG₂, e.g., i₁*OG₁,i₃*OG₁, i₄*OG₁, i₂*OG₂, i₃*OG₂, to generate weight differences Δw₁₁,Δw₃₁, Δw₄₁, Δw₂₂, and Δw₃₂. Further, the computing unit 710 may beconfigured to subtract the weight differences, e.g., Δw₁₁, Δw₃₁, Δw₄₁,Δw₂₂, and Δw₃₂, from the modified weight values, e.g., w₁₁, w₃₁, w₄₁,w₂₂, w₃₂, to generate one or more updated weight values, e.g., w₁₁′,w₃₁′, w₄₁′, w₂₂′, w₃₂′.

Further in the example backward propagation process illustrated in FIG.1, the computing unit 710 may be configured to calculate one or moreinput gradients based on the connection values and the output gradients.

In more detail, the computing unit 710 may be configured to multiply themodified weight values with the output gradients. For example, thecomputing unit 710 maybe configured to multiply the modified weightvalues, e.g., w₁₁, w₃₁, w₄₁, w₂₂, w₃₂, respectively with the outputgradients OG₁ and OG₂, e.g., w₁₁*OG₁, w₃₁*OG₁, w₄₁*OG₁, w₂₂*OG₂,w₃₂*OG₂, to generate one or more one or more multiplication results. Thecomputing unit 710 may be configured to add the multiplication resultsto generate an intermediate sum and multiply a learning rate with theintermediate sum to generate an intermediate multiplication result. Thecomputing unit 710 may be further configured to apply a derivative of anactivation function to the intermediate multiplication result togenerate one or more input gradients.

The calculated input gradients and the updated weight values may betransmitted to and temporarily stored in the data cache 712 and/or theweight cache 714.

FIG. 8 is a block diagram illustrating another example MNN accelerationprocessor in which data modification for neural networks may beimplemented. As depicted, components in the example MNN accelerationprocessor 206 may be the same or similar to the corresponding componentsshown in FIG. 7 or may be configured to perform the same or similaroperations to those shown in FIG. 7 except that a data modifier 802 maybe implemented between a DMA module 804, an data cache 812, and a weightcache 814.

The data modifier 802, similar to the data modifier 702, may beconfigured to generate the connection values based on the weight valuesand further modify the weight values and the input data based on theconnection values. The data modifier 802 may be further configured tosimilarly update the modified weight values and calculate the inputgradients.

FIG. 9 is a block diagram illustrating another example MNN accelerationprocessor in which data modification for neural networks may beimplemented.

As depicted, components in the example MNN acceleration processor 206may be the same or similar to the corresponding components shown in FIG.7 or may be configured to perform the same or similar operations tothose shown in FIG. 7 except that a data modifier 902 may be implementedbetween a DMA module 904 and an data cache 912.

The data modifier 902, similar to the data modifier 702, may beconfigured to generate the connection values based on the weight values.However, in the example illustrated in FIG. 9, the data modifier 902 maybe configured to only modify the input data based on the connectionvalues. For example, a pruning module of the data modifier 902 may beconfigured to delete one or more groups of input data that correspond toconnection values of zero. The modified input data may be transmitted bythe data modifier 902 to the data cache 912.

The data modifier 902 may be further configured to retrieve one or moreoutput gradients from the DMA module 904 and transmit the outputgradients to the data cache 912. Upon receiving the output gradientsfrom the data cache 912, a computing unit 910 may be configured tosimilarly update the modified weight values and calculate the inputgradients.

FIG. 10 is a block diagram illustrating another example MNN accelerationprocessor in which data modification for neural networks may beimplemented.

As depicted, components in the example MNN acceleration processor 206may be the same or similar to the corresponding components shown in FIG.7 or may be configured to perform the same or similar operations tothose shown in FIG. 7 except that a data modifier 1002 may beimplemented between a DMA module 1004 and a weight cache 1014.

The data modifier 1002, similar to the data modifier 702, may beconfigured to generate the connection values based on the weight values.However, in the example illustrated in FIG. 10, the data modifier 1002may be configured to only modify the weight values based on theconnection values. For example, a pruning module of the data modifier1002 may be configured to delete one or more weight values thatcorrespond to connection values of zero. The modified weight values maybe transmitted by the data modifier 1002 to the weight cache 1014.

The data modifier 1002 may be further configured to retrieve one or moreoutput gradients from the DMA module 1004 and transmit the outputgradients to the weight cache 1014. Upon receiving the output gradientsfrom the weight cache 1014, a computing unit 1010 may be configured tosimilarly update the modified weight values and calculate the inputgradients.

FIG. 11 is a block diagram illustrating an example data modifier702/802/902/1002 in an example MNN acceleration processor in which datamodification for neural networks may be implemented.

As depicted, the example data modifier 702/802/902/1002 may include aconnection value generator 1102 configured to generate one or moreconnection values based on the weight values.

In the example illustrated in FIG. 4A, the connection value generator1102 may be configured to generate the connection values based on theweight values w₁₁, w₂₁, w₃₁, and w₄₁. Since the absolute value of theexample weight value w₂₁ is less than the first threshold value and theabsolute values of other weight values w₁₁, w₃₁, and w₄₁ are greaterthan the second threshold value, the data modifier 702 may be configuredto generate the connection values for output node o₁ as 1011. Similarly,the connection values for o₂ may be generated as 0110 when the weightvalues w₁₂ and w₄₂ are less than or equal to the first threshold value.

In the example illustrated in FIG. 4B, the connection value generator1102 may be similarly configured to generate the connection values basedon the weight values. For example, the connection value generator 1102may be configured not to generate a connection value that corresponds toa weight value, of which an absolute value is less than or equal to afirst threshold value. In more detail, a connection value may bedetermined by the distances between different input nodes thatcorrespond to those weight values, of which the absolute values areequal to or greater than the second threshold value. With respect to theexample weight values, w₁₁, w₃₁, and w₄₁, of which the absolute valuesare greater than the second threshold value, the connection value forinput node i₁ may be set to a value equal to the distance between theprevious connected input node and the current input node. Thus, sincethe distance between input node i₁ and the previous connected node (alsoi₁ here) is zero, the connection value for i₁ may be set to zero. Withrespect to input node i₃, since the distance between input node i₃ andthe first input node (i₁) is 2, the connection value for i₃ may be setto 2. Thus, the connection values may be generated by the connectionvalue generator 1102 as 021.

The example data modifier 702/802/902/1002 may further include a pruningmodule 1104 configured to modify the input data and the weight valuesbased on the generated connection values. For example, with respect tothe output node o₁, based on the connection values of 1011, the pruningmodule 1104 may be configured to delete the input data corresponding tothe connection values of zero, e.g., i₂, and to delete the weight valuecorresponding to the connection values of zero, e.g., w₂₁. With respectto the output node o₂, based on the connection values of 0110, thepruning module 1104 may be configured to delete the input datacorresponding to the connection values of zero, e.g., i₁ and i₄, and todelete the weight values corresponding to the connection values of zero,e.g., w₁₂ and w₄₂. Thus, input data 11, i₃, i₄, i₂, i₃ and the weightvalues w₁₁, w₃₁, w₄₁, w₂₂, w₃₂ may be output by the pruning module 1104.

FIG. 12 is a flow chart of aspects of an example method 1200 formodifying data for neural networks. Operations in the example method1200 may be performed by components described in accordance with FIGS.7-11.

At block 1202, the example method 1200 may include receiving, by aconnection value generator, one or more groups of input data and one ormore weight values. For example, the connection value generator 1102configured to receive the input data and the weight values from thememory 208 or the DMA module 704/804/904/1004.

At block 1204, the example method 1200 may include generating, by theconnection value generator, one or more connection values based on theone or more weight values. For example, the connection value generator1102 configured to generate one or more connection values based on theweight values.

In the example illustrated in FIG. 4A, the connection value generator1102 may be configured to generate the connection values based on theweight values w₁₁, w₂₁, w₃₁, and w₄₁. Since the absolute value of theexample weight value w₂₁ is less than the first threshold value and theabsolute values of other weight values w₁₁, w₃₁, and w₄₁ are greaterthan the second threshold value, the data modifier 702 may be configuredto generate the connection values for output node o₁ as 1011. Similarly,the connection values for o₂ may be generated as 0110 when the weightvalues w₁₂ and w₄₂ are less than or equal to the first threshold value.

In the example illustrated in FIG. 4B, the connection value generator1102 may be similarly configured to generate the connection values basedon the weight values. For example, the connection value generator 1102may be configured not to generate a connection value that corresponds toa weight value, of which an absolute value is less than or equal to afirst threshold value. In more detail, a connection value may bedetermined by the distances between different input nodes thatcorrespond to those weight values, of which the absolute values areequal to or greater than the second threshold value. With respect to theexample weight values, w₁₁, w₃₁, and w₄₁, of which the absolute valuesare greater than the second threshold value, the connection value forinput node i₁ may be set to a value equal to the distance between theprevious connected input node and the current input node. Thus, sincethe distance between input node i₁ and the previous connected node (alsoi₁ here) is zero, the connection value for i₁ may be set to zero. Withrespect to input node i₃, since the distance between input node i₃ andthe first input node (i₁) is 2, the connection value for i₃ may be setto 2. Thus, the connection values may be generated by the connectionvalue generator 1102 as 021.

At block 1206, the example method 1200 may include modifying, by apruning module, the one or more groups of input data and the one or moreweight values based on the connection values. For example, the pruningmodule 1104 configured to modify the input data and the weight valuesbased on the generated connection values. For example, with respect tothe output node o₁, based on the connection values of 1011, the pruningmodule 1104 may be configured to delete the input data corresponding tothe connection values of zero, e.g., i₂, and to delete the weight valuecorresponding to the connection values of zero, e.g., w₂₁. With respectto the output node o₂, based on the connection values of 0110, thepruning module 1104 may be configured to delete the input datacorresponding to the connection values of zero, e.g., i₁ and i₄, and todelete the weight values corresponding to the connection values of zero,e.g., with and w₄₂. Thus, input data i₁, i₃, i₄, i₂, i₃ and the weightvalues w₁₁, w₃₁, w₄₁, w₂₂, w₃₂ may be output by the pruning module 1104.

At block 1208, the example method 1200 may include updating, by acomputing unit, the one or more weight values based on the connectionvalues and one or more output gradients. For example, the computing unit710 may be configured to update the one or more weight values based onthe modified weight values and the modified input data.

example, the computing unit 710 may be configured to update the one ormore weight values based on the connection values and one or more outputgradients, e.g., output gradients 104B. The output gradients 104B may betemporarily stored in the data cache 712. As shown in FIG. 1, the outputgradients 104B may refer to the input gradients 106B that aretransmitted from another layer, with or without other operations.

In more detail, the computing unit 710 may be configured to multiply themodified input data with the output gradients 104B to generate one ormore weight differences. Further to the example illustrated in FIG. 4A,the computing unit 710 may be configured to retrieve the outputgradients OG₁ and OG₂ respectively for the output nodes o₁ and o₂ fromthe data cache 712. The input data modified with respect to the outputnode of may be i₃, and i₄; the input data modified with respect to theoutput node o₂ may be i₂ and i₃. The computing unit 710 may beconfigured to multiply the modified input data i₁, i₃, i₄, i₂, i₃respectively with the output gradients OG₁ and OG₂, e.g., i₁*OG₁,i₃*OG₁, i₂*OG₂, i₃*OG₂, to generate weight differences Δw₁₁, Δw₃₁, Δw₄₁,Δw₂₂, and Δw₃₂. Further, the computing unit 710 may be configured tosubtract the weight differences, e.g., Δw₁₁, Δw₃₁, Δw₄₁, Δw₂₂, and Δw₃₂,from the modified weight values, e.g., w₁₁, w₃₁, w₄₁, w₂₂, w₃₂, togenerate one or more updated weight values, e.g., w₁₁′, w₃₁′, w₄₁′,w₂₂′, w₃₂′.

At block 1210, the example method 1200 may include calculating, by acomputing unit, one or more input gradients based on the connectionvalues and one or more output gradients. For example, the computing unit710 may be configured to calculate one or more input gradients based onthe connection values and the output gradients.

In more detail, the computing unit 710 may be configured to multiply themodified weight values with the output gradients. For example, thecomputing unit 710 may be configured to multiply the modified weightvalues, e.g., w₁₁, w₃₁, w₄₁, w₂₂, w₃₂, respectively with the outputgradients OG₁ and OG₂, e.g., w₁₁*OG₁, w₃₁*OG₁, w₄₁*OG₁, w₂₂*OG₂,w₃₂*OG₂, to generate one or more one or more multiplication results. Thecomputing unit 710 may be configured to add the multiplication resultsto generate an intermediate sum and multiply a learning rate with theintermediate sum to generate an intermediate multiplication result. Thecomputing unit 710 may be further configured to apply a derivative of anactivation function to the intermediate multiplication result togenerate one or more input gradients.

The process or method described in the above accompanying figures can beperformed by process logic including hardware (for example, circuit,specific logic etc.), firmware, software (for example, a software beingexternalized in a non-transitory computer-readable medium), or thecombination of the above two. Although the process or method isdescribed above in a certain order, it should be understood that someoperations described may also be performed in different orders. Inaddition, some operations may be executed concurrently rather than inorder.

In the above description, each embodiment of the present disclosure isillustrated with reference to certain illustrative embodiments.Apparently, various modifications may be made to each embodiment withoutgoing beyond the wider spirit and scope of the present disclosurepresented by the affiliated claims. Correspondingly, the description andaccompanying figures should be understood as illustration only ratherthan limitation. It is understood that the specific order or hierarchyof steps in the processes disclosed is an illustration of exemplaryapproaches. Based upon design preferences, it is understood that thespecific order or hierarchy of steps in the processes may be rearranged.Further, some steps may be combined or omitted. The accompanying methodclaims present elements of the various steps in a sample order and arenot meant to be limited to the specific order or hierarchy presented.

The previous description is provided to enable any person skilled in theart to practice the various aspects described herein. Variousmodifications to these aspects will be readily apparent to those skilledin the art, and the generic principles defined herein may be applied toother aspects. Thus, the claims are not intended to be limited to theaspects shown herein but is to be accorded the full scope consistentwith the language claims, wherein reference to an element in thesingular is not intended to mean “one and only one” unless specificallyso stated, but rather “one or more.” Unless specifically statedotherwise, the term “some” refers to one or more. All structural andfunctional equivalents to the elements of the various aspects describedherein that are known or later come to be known to those of ordinaryskill in the art are expressly incorporated herein by reference and areintended to be encompassed by the claims. Moreover, nothing disclosedherein is intended to be dedicated to the public regardless of whethersuch disclosure is explicitly recited in the claims. No claim element isto be construed as a means plus function unless the element is expresslyrecited using the phrase “means for.”

Moreover, the term “or” is intended to mean an inclusive “or” ratherthan an exclusive “or.” That is, unless specified otherwise, or clearfrom the context, the phrase “X employs A or B” is intended to mean anyof the natural inclusive permutations. That is, the phrase “X employs Aor B” is satisfied by any of the following instances: X employs A; Xemploys B; or X employs both A and B. In addition, the articles “a” and“an” as used in this application and the appended claims shouldgenerally be construed to mean “one or more” unless specified otherwiseor clear from the context to be directed to a singular form.

We claim:
 1. A neural network processor, comprising: a connection valuegenerator of a data modifier configured to: receive one or more groupsof input data and one or more weight values, generate one or moreconnection values based on the one or more weight values; and a pruningmodule of the data modifier configured to modify the one or more weightvalues based on the connection values.
 2. The neural network processorof claim 1, further comprising a computing unit configured to: multiplyone or more output gradients with the input data to generate one or moreweight differences, and subtract the one or more weight differences fromthe one or more modified weight values to generate one or more updatedweight values.
 3. The neural network processor of claim 2, wherein thedata modifier is connected to a memory and a direct memory access (DMA)module, wherein the data modifier is configured to store the one or moreoutput gradients and the input data in the memory, and wherein thecomputing unit is further configured to store the output gradients andthe input data respectively in a weight cache and a data cache.
 4. Theneural network processor of claim 2, wherein the computing unit isfurther configured to: multiply the one or more output gradients withthe one or more modified weight values to generate one or moremultiplication results, add the one or more multiplication results togenerate an intermediate sum, multiply the intermediate sum with alearning rate to generate an intermediate multiplication result, andapply a derivative of an activation function to the intermediatemultiplication result to generate one or more input gradients.
 5. Theneural network processor of claim 4, wherein the data modifier isconnected to a memory and a direct memory access (DMA) module, whereinthe data modifier is configured to store the modified weight values andthe one or more output gradients in the memory, and wherein thecomputing unit is further configured to: read the modified weight valuesand the one or more output gradients from the memory in response to aninstruction received from a controller, and store the one or more outputgradients and the weight values respectively in a weight cache and adata cache.
 6. The neural network processor of claim 1, furthercomprising a computing unit configured to respectively multiply themodified groups of input data with the modified weight values togenerate one or more groups of output data.
 7. The neural networkprocessor of claim 1, wherein the data modifier is connected to a weightcache and a data cache, and wherein the data modifier is configured tostore the modified weight values and the input data respectively in theweight cache and the data cache.
 8. The neural network processor ofclaim 1, wherein one or more of the connection values are generated aszero when absolute values of the weight values that correspond to theone or more of the connection values are less than or equal to a firstthreshold value.
 9. The neural network processor of claim 1, wherein oneor more of the connection values are generated as one when absolutevalues of the weight values that correspond to the one or more of theconnection values are greater than or equal to a second threshold value.10. The neural network processor of claim 1, wherein the connectionvalues are respectively generated based on a distance between inputnodes corresponding to the one or more groups of input data.
 11. Amethod for modifying data for neural networks, comprising: receiving, bya connection value generator of a data modifier, one or more groups ofinput data and one or more weight values; generating, by the connectionvalue generator of the data modifier, one or more connection valuesbased on the one or more weight values; and modifying, by a pruningmodule of the data modifier, the one or more weight values based on theconnection values.
 12. The method of claim 11, further comprisingmultiplying, by a computing unit, the one or more output gradients withthe input data to generate one or more weight differences; andsubtracting, by the computing unit, the one or more weight differencesfrom the one or more modified weight values to generate one or moreupdated weight values.
 13. The method of claim 12, further comprising:storing, by the data modifier, the one or more output gradients and theinput data in a memory, wherein the data modifier is connected to thememory and a direct memory access (DMA) module, and storing, by thecomputing unit, the output gradients and the input data respectively ina weight cache and a data cache.
 14. The method of claim 12, furthercomprising: multiplying, by the computing unit, the one or more outputgradients with the one or more modified weight values to generate one ormore multiplication results, adding, by the computing unit, the one ormore multiplication results to generate an intermediate sum,multiplying, by the computing unit, the intermediate sum with a learningrate to generate an intermediate multiplication result, and applying, bythe computing unit, a derivative of an activation function to theintermediate multiplication result to generate the one or more inputgradients.
 15. The method of claim 14, further comprising: storing, bythe data modifier, the modified weight values and the one or more outputgradients in a memory, wherein the data modifier is connected to thememory and a direct memory access (DMA) module, reading, by thecomputing unit, the modified weight values and the one or more outputgradients from the memory in response to an instruction received from acontroller, and storing, by the computing unit, the one or more outputgradients and the weight values respectively in a weight cache and adata cache.
 16. The method of claim 11, further comprising multiplying,by a computing unit, the modified groups of input data with the modifiedweight values respectively to generate one or more groups of outputdata.
 17. The method of claim 11, further comprising storing, by thedata modifier, the modified weight values and the input datarespectively in a weight cache and a data cache, wherein the datamodifier is directly connected to the weight cache and the data cache.18. The method of claim 11, further comprising generating, by theconnection value generator, one or more of the connection values as zerowhen absolute values of the weight values that correspond to the one ormore of the connection values are less than or equal to a firstthreshold value.
 19. The method of claim 11, further comprisinggenerating, by the connection value generator, one or more of theconnection values as one when absolute values of the weight values thatcorrespond to the one or more of the connection values are greater thanor equal to a second threshold value.
 20. The method of claim 11,further comprising generating, by the connection value generator, basedon a distance between input nodes corresponding to the one or moregroups of input data.
 21. A neural network processor for training neuralnetworks, comprising: a connection value generator of a data modifierconfigured to: receive one or more groups of input data and one or moreweight values at one or more input nodes of a current layer, generateone or more connection values based on the one or more weight values; apruning module of the data modifier configured to modify the one or moreweight values based on the connection values; and a computing unitconfigured to: update the one or more modified weight values of thecurrent layer based on the input data and one or more output gradientsreceived at one or more output nodes of the current layer from a nextlayer, calculate one or more input gradients of the current layer basedon the modified weight values and the one or more output gradients, andrespectively multiply the input data with the modified weight values togenerate one or more groups of output data at the one or more outputnodes of the current layer.
 22. The neural network processor of claim21, wherein the data modifier is connected to a memory and a directmemory access (DMA) module, wherein the data modifier is configured tostore the one or more output gradients received at the one or moreoutput nodes from the next layer and the input data in the memory, andwherein the computing unit is further configured to store the outputgradients and the input data respectively in a weight cache and a datacache.
 23. The neural network processor of claim 21, wherein the datamodifier is connected to a memory and a direct memory access (DMA)module, wherein the data modifier is configured to store the modifiedweight values and the one or more output gradients in the memory, andwherein the computing unit is further configured to: read the modifiedweight values and the one or more output gradients from the memory inresponse to an instruction received from a controller, and store the oneor more output gradients and the weight values respectively in a weightcache and a data cache.